# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI="1"

inherit eutils rpm

MY_PV="3.13-3"
MY_P="${PN}-${MY_PV}"

DESCRIPTION="HighPoint RocketRaid GUI configuration tool."
HOMEPAGE="http://www.highpoint-tech.com"

SRC_URI="http://www.highpoint-tech.com/BIOS_Driver/HRM/Linux/GUI-Linux-3.13-4-1214.tgz"

LICENSE=""

SLOT="0"

KEYWORDS="~amd64 ~x86"

IUSE="+server"

RESTRICT="strip mirror"

DEPEND="x11-libs/libXi
	x11-libs/libXext
	x11-libs/libX11
	x11-libs/libXau
	x11-libs/libXdmcp
	=x11-libs/gtk+-1.2*
	=dev-libs/glib-1.2*
	server? ( =sys-block/hptsvr-3.13.4* )"

RDEPEND="${DEPEND}"

src_unpack() {
	unpack ${A}
	cd "${WORKDIR}"

	einfo "Removing unnessary files from WORKDIR."
	rm hptsvr-*.rpm

	if use amd64; then
		einfo "Removing i586 rpm from WORKDIR."
		rm "${WORKDIR}/${MY_P}.i586.rpm"
		einfo "Unpacking ${MY_P}.x86_64.rpm"
		rpm_unpack "${WORKDIR}/${MY_P}.x86_64.rpm"
	elif use x86; then
		einfo "Removing x86_64 rpm from WORKDIR."
		rm "${WORKDIR}/${MY_P}.x86_64.rpm"
		einfo "Unpacking ${MY_P}.i586.rpm"
		rpm_unpack "${WORKDIR}/${MY_P}.i586.rpm"
	fi
}

src_install() {
	cp -R "${WORKDIR}/usr" "${D}/" || die "Install failed."
	dodir /usr/bin
	dosym /usr/share/hpt/hptraid-3.13/hptraid /usr/bin/hptraid
	dodoc "${WORKDIR}/README.txt"
	for dir in /usr/local/bin /usr/bin /usr/X11R6/bin; do
		if [ -f "${dir}/firefox" ] ; then
			dosym "${dir}/firefox" /usr/bin/hptbrowser
			break
		elif [ -f "${dir}/mozilla" ] ; then
			dosym "${dir}/mozilla" /usr/bin/hptbrowser
			break
		elif [ -f "${dir}/htmlview" ] ; then
			dosym "${dir}/htmlview" /usr/bin/hptbrowser
			break
		fi
	done
	domenu "${FILESDIR}/hptraid.desktop"
}
